package cn.mcsys.myadmin.modules.air.web;

import cn.mcsys.myadmin.common.web.JsonResult;
import cn.mcsys.myadmin.modules.air.entity.AirRidePoint;
import cn.mcsys.myadmin.modules.air.service.AirRidePointService;
import cn.mcsys.myadmin.modules.air.vo.AirRidePointLonlatVO;
import cn.mcsys.myadmin.modules.viewer.entity.AirViewerUser;
import cn.mcsys.myadmin.modules.viewer.service.AirViewerUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author bobo
 * @create 2018-09-20 10:02
 * @desc ${DESCRIPTION}
 **/
@Controller
@RequestMapping(value = "${adminPath}/air/share")
public class AirShareController {

    @Autowired
    private AirRidePointService airRidePointService;

    @Autowired
    private AirViewerUserService airViewerUserService;


    /**
     * 所有观众手机号码
     * @return
     */
    @GetMapping("getViewerPhone")
    @ResponseBody
    public JsonResult getViewerPhone(){
        List<AirViewerUser> allList = airViewerUserService.findAllList();
        List<String> list = new ArrayList<>();
        for (AirViewerUser user : allList) {
            if(user.getPhone()!=null){
                list.add(user.getPhone());
            }
        }
        return JsonResult.success();
    }

    /**
     * 每个乘车点经纬度
     * @return
     */
    @GetMapping("getRidePointLonlat")
    @ResponseBody
    public JsonResult getRidePointLonlat(){
        List<AirRidePoint> allList = airRidePointService.findAllList();
        List<AirRidePointLonlatVO> list = new ArrayList<>();
        for (AirRidePoint point : allList) {
            AirRidePointLonlatVO lonlatVO = new AirRidePointLonlatVO();
            lonlatVO.setName(point.getName());
            lonlatVO.setLon(point.getLon());
            lonlatVO.setLat(point.getLat());
            list.add(lonlatVO);
        }
        return JsonResult.success(list);
    }
}
